#include "Assert.h"

#include "Test.h"

namespace {
	class RunnableStub : public Runnable {
		virtual void run() {
		}
	};

	Test* test1;
	Test* test2;
	Test* test3;
	TestContainer* testContainer;

	BEFORE {
		test1 = new Test;
		test1->name = "test1";

		test2 = new Test;
		test2->name = "test2";

		test3 = new Test;
		test3->name = "test3";
		
		testContainer = new TestContainer;

		testContainer->addTest("suite1", *test1);
		testContainer->addTest("suite1", *test2);
		testContainer->addTest("suite2", *test3);
	}

	AFTER {
		delete test1;
		delete test2;
		delete test3;
		delete testContainer;
	}

	TEST(FindSuites) {
		vector<string> expectedSuites;
		expectedSuites.push_back("suite1");
		expectedSuites.push_back("suite2");
		ASSERT_EQUALS(expectedSuites, testContainer->findSuites());
	}

	TEST(FindTestsBySuite) {
		vector<Test> expectedTestsSuite1;
		expectedTestsSuite1.push_back(*test1);
		expectedTestsSuite1.push_back(*test2);
		
		vector<Test> expectedTestsSuite2;
		expectedTestsSuite2.push_back(*test3);

		ASSERT_EQUALS(expectedTestsSuite1, testContainer->findTestsBySuite("suite1"));
		ASSERT_EQUALS(expectedTestsSuite2, testContainer->findTestsBySuite("suite2"));
	}

	TEST(FindBeforeAfter) {
		Runnable* before1 = new RunnableStub();
		Runnable* after1 = new RunnableStub();
		Runnable* before2 = new RunnableStub();
		
		testContainer->addBefore("suite1", before1);
		testContainer->addAfter("suite1", after1);
		testContainer->addBefore("suite2", before2);

		ASSERT_EQUALS(before1, testContainer->findBeforeBySuite("suite1"));
		ASSERT_EQUALS(after1, testContainer->findAfterBySuite("suite1"));
		ASSERT_EQUALS(before2, testContainer->findBeforeBySuite("suite2"));
	}
}